﻿using Heimdallr.Net;
using System;
using System.Net;

namespace Heimdallr.Sample.ChatRoom.Server
{
    class CustomMultipartResponseModule : HttpMultipartResponseModule
    {
        public CustomMultipartResponseModule()
            : base(WebRequestMethods.Http.Get, "svc-bin/chatroom/response/", HttpModuleCredentialType.None)
        {
        }

        protected override void ContextRegistered(HttpResponseContext response)
        {
            Console.WriteLine("{0} online.", response.Description.RemoteEndPoint);
        }

        protected override void ContextUnregistered(HttpResponseContext response)
        {
            Console.WriteLine("{0} offline.", response.Description.RemoteEndPoint);
        }

        protected override object BeforePublish(HttpOperationDescription description, ref Notification notification)
        {
            Console.WriteLine(string.Format("Publish a message to {0}. MIME: {1}. Length: {2}",
                description.RemoteEndPoint,
                notification.ContentType,
                notification.ContentLength));

            return base.BeforePublish(description, ref notification);
        } 
    }
}